﻿
@model YouWei.Infrastructure.Models.CommentDto

@{
    ViewBag.Title = "产品详情";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<section class="content-header">
    <h1>
        产品管理
        <small></small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
        <li class="active">内容详情</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">
                    <table class="table table-striped">
                        <tr>
                            <td width="250px;">名称</td>
                            <td colspan="3">@Model.CommentName</td>
                        </tr>
                        <tr>
                            <td width="250px;">审核状态</td>
                            @if (Model.ExamineStatus == 0)
                            {
                            <td colspan="3">
                                待审核 &nbsp;&nbsp;
                                <input type="button" class="btn btn-primary" id="examineY" value="通过" />&nbsp;&nbsp;
                                <input type="button" class="btn btn-primary" id="examineN" value="拒绝" />&nbsp;&nbsp;
                                @*这里逻辑注意，必须区分0和1，如果是2的话不做处理，2代表丽人馆*@
                                @if (Model.IsHot == 0)
                                {
                                    <input type="button" class="btn btn-primary" onclick="setHot(1)" value="设置热门" />
                                }
                                @if (Model.IsHot == 1)
                                {
                                    <input type="button" class="btn btn-primary" onclick="setHot(0)" value="取消热门" />
                                }
                                &nbsp; &nbsp;
                                @*只有丽人馆有置顶按钮，为了保证至少1个置顶，所以不允许取消*@
                                @if (Model.CommentSection == 3)
                                {
                                    <input type="button" class="btn btn-primary" onclick="setHot(2)" value="设置置顶" />
                                }
                            </td>
                            }
                            @if (Model.ExamineStatus == 1)
                            {
                                <td colspan="3">通过</td>
                            }
                            @if (Model.ExamineStatus == 2)
                            {
                                <td colspan="3">未通过</td>

                            }
                        </tr>
                        <tr>
                            <td>是否可见</td>
                            @if (@Model.IsShow == 1)
                            {
                                <td>是</td>
                            }
                            @if (@Model.IsShow == 0)
                            {
                                <td>否</td>
                            }
                            <td>产品类别</td>
                            @if (Model.CommentType == 1)
                            {
                                <td>手动</td>
                            }
                            @if (Model.CommentType == 2)
                            {
                                <td>抓取</td>
                            }
                            @if (Model.CommentType == 3)
                            {
                                <td>链接</td>
                            }
                        </tr>
                        <tr>
                            <td>创建时间</td>
                            <td>@Model.CreateDate.ToString("yyyy-MM-dd HH:mm")</td>
                            <td>更新时间</td>
                            <td>@Model.UpdateDate.ToString("yyyy-MM-dd HH:mm")</td>
                        </tr>
                        <tr>
                            <td>简图</td>
                            <td colspan="3"><img class="" style="width:100px;height:100px;" src="@Model.HeadImgUrl" /> </td>
                        </tr>
                        <tr>
                            <td>简介</td>
                            <td colspan="3">@Model.CommentDesc</td>
                        </tr>
                        <tr>
                            <td>详情</td>
                            <td colspan="3" rowspan="3">@Html.Raw(Model.Detail) </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
@section scriptsBottom{
    <script>
        $(function () {
            $("#examineY").on("click", function () {
                BMCW.DataConfirm("确定通过审核？", function () {
                    setExamineStatus(1);
                });
            })
            $("#examineN").on("click", function () {
                BMCW.DataConfirm("确定通过审核？", function () {
                    setExamineStatus(2);
                });
            })

            function setExamineStatus(status) {
                 var id = "@Model.CommentID";
                BMCW.ajax({
                    url: "@Url.Action("UpdateCommentExamineStatus","Product")?id=" + id + "&status=" + status,
                        type:"POST",
                        success: function (data) {
                            if (data.status == 0) {
                                BMCW.alert("更新状态成功");
                                setTimeout(function () {
                                    window.location.reload();
                                }, 2000);
                            } else {
                                BMCW.alert(data.message);
                            }
                        }
                    });
            }
        }());
        function setHot(isHot) {
                var id = "@Model.CommentID";
                BMCW.ajax({
                    url: "@Url.Action("UpdateCommentIsHot", "Product")?id=" + id + "&isHot=" + isHot,
                        type:"POST",
                        success: function (data) {
                            if (data.status == 0) {
                                BMCW.alert("更新状态成功");
                                setTimeout(function () {
                                    window.location.reload();
                                }, 2000);
                            } else {
                                BMCW.alert(data.message);
                            }
                        }
                    });
            }
    </script>
}